<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="ihis.model.*" %>
<%@ page import="ihis.core.*" %>

<%@ include file="filter.jsp" %>
<%
	TaskFilter taskFilter = new TaskFilter(filter);
	if(taskFilter.getStartDate() == null && taskFilter.getReportDate()!= null)
	{
		sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		taskFilter.setStartDate(sdf.parse(filter.getReportDate()));
	}
	String taskType = request.getParameter("taskType");
	if(!IHISUtil.isEmpty(taskType)){
		int iTaskType = Integer.parseInt(taskType);
		taskFilter.setTaskType(iTaskType);
	}
	Vector<Task> tasks = tms.getTaskList(taskFilter);
%>
    
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>Task List</title>
    <link rel="stylesheet" href="script/jquery.mobile-1.0a4.1.min.css"/>
    <link rel="stylesheet" href="script/ihis.css"/>
    <script src="script/jquery-1.6.min.js"></script>
    <script src="script/ihis.schedule.js"></script>
    <script src="script/jquery.mobile-1.0a4.1.min.js"></script>
</head>
<body>
	<div id="taskPage" data-role="page">
	
    <script type="text/javascript">
    
    </script>
    
		<div data-role="header" data-position="fixed">
			<a href="#" id="backButton" data-icon="arrow-l" data-transition="reverse">Back</a>
			<h1>할일 목록</h1>
			<a href="#" id="homeButton" data-icon="home" data-transition="flip">Home</a>
		</div>
	
		<div data-role="content">
			<ul data-role="listview" data-inset="false" data-filter="true">

<%
	sdf = new SimpleDateFormat("yyyy-MM-dd");
	StringBuilder sb = new StringBuilder();
	if(tasks != null)
	for(Task t : tasks){
		sb = new StringBuilder();
		sb.append(tms.getUserName(t.getOwnerId())).append(" / ")
			.append(tms.getTeamName(t.getTeamId())).append(" / ")
			.append(t.getProgressRatio()).append("% / ")
			.append(t.getStatusMessage()).append(" / ");
		if(t.getStartDate() != null)
			sb.append(sdf.format(t.getStartDate()) + "~");
		if(t.getStartDate() != null)
			sb.append(sdf.format(t.getDueDate()));
%>			
				<li>
					<h4><%= t.getSubject() %></h4>
					<p><%= sb.toString() %><p>
				</li>
<%
	}
%>
		</div> 
		
		<div data-role="footer" data-position="fixed">
			<a href="task.jsp" data-icon="refresh" data-rel="refresh" data-transition="flip">Refresh</a>
			<!-- a href="task.jsp" data-icon="check" data-rel="refresh" data-transition="flip">Name</a>
			<a href="task.jsp" data-icon="check" data-rel="refresh" data-transition="flip">Team</a>
			<a href="task.jsp" data-icon="check" data-rel="refresh" data-transition="flip">Status</a-->
		</div>
		
	</div>
</body>
</html>